home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / audio / harmonizer / README < prev   
Encoding:
Text File  |  1994-08-02  |  3.3 KB  |  89 lines

  1.  
  2.            ~4Dgifts/toolbox/src/exampleCode/audio/harmonizer README
  3.  
  4.  
  5.      Simple harmonizer - a real-time audio pitch bender example program
  6.  
  7.  
  8.      Usage: harmonizer note1 <note2 note3 ... >
  9.      
  10.          Output is to the standard Indigo audio device (speaker).
  11.      
  12.          Notes are specified by an integer relating the note in 
  13.     half steps to middle C.  
  14.      
  15.          Middle C would be 0. C# would be 1
  16.      
  17.          for no effect at all     :      harmonizer 0
  18.          for the chipmunk effect  :     harmonizer 12
  19.          for a deep voice machine :    harmonizer -7
  20.          to simulate a major cord :     harmonizer 0 4 7
  21.  
  22.      
  23.      Comments: 
  24.      
  25.          Advise running as root or suid root to take advantage of
  26.          memory pinning and non-degrading high priority of audio 
  27.     process.  To make harmonizer setuid root, run the following
  28.     command:
  29.                    chown root harmonizer ; chmod 4755 harmonizer
  30.  
  31.          Libraries you need to compile with come from the Digital
  32.          Media Development option, now up to version 1.1 (for 
  33.          systems running IRIX 4.0.X) and version 1.2 (for systems
  34.          running IRIX 5)
  35.      
  36.          Pitch shifting of realtime input from the microphone.
  37.      
  38.          Code isn't optimized. 
  39.      
  40.          With the computing power of the indigo R3k, about 4 notes
  41.          can be harmonized simultaneously without a problem.
  42.          R4k does well up to even 8 notes.
  43.  
  44.  
  45.      Harmonizer algorithm :
  46.  
  47.            Assume that the original pitch that we're bending
  48.            has its orginal pitch at MIDDLEC.  This is
  49.            an arbitrary starting point and could be anything. 
  50.  
  51.            To halve the pitch (move it down an octave) we 
  52.            duplicate samples.  AS expected, only half of the 
  53.            input buffer is used as it  gets copied to the audio 
  54.            output buffer. 
  55.  
  56.            To double the pitch (move it up an octave) we 
  57.            just copy every other sample of the original sound 
  58.            into the audio output buffer.
  59.  
  60.            Both of these are handled by computing the ratio
  61.            of the original pitch to the desired output pitch.
  62.            And skipping/repeating samples accordingly.
  63.            
  64.            For an octave higher, the ratio is 2.0:1.0 and
  65.            samples are skipped. For an octave lower, the
  66.            ration is 0.5:1.0 and samples are doubled.
  67.            For a musical interval of a perfect fifth higher,
  68.            the ration is 1.5:1.0, etc. 
  69.  
  70.            To make calculations based on a piano keyboard, the
  71.            TWELFTH_ROOT_OF_TWO is used as a multiplier to
  72.            find any pitch on the piano keyboard.  The number
  73.            of half-steps away a pitch is from MIDDLEC is
  74.            the power that the ratio is raised to. Thus,
  75.            the C-sharp above MIDDLEC has a ratio of
  76.            TWELFTH_ROOT_OF_TWO:1.0 with respect to MIDDLEC.
  77.            The D Natural above MIDDLE C is
  78.            TWELFTH_ROOT_OF_TWO ^ 2 : 1.0 with repect to
  79.            MIDDLEC and so forth.
  80.  
  81.            The output pitch is based on the sampled audio input 
  82.            only. So this the time over which the pitch is 
  83.            harmonized is discetized and only the audio input
  84.            buffer for that duration of time is used as the
  85.            sample input for the algorithm.  Consequently,
  86.            a continuous version of this algorithm (ala
  87.            glissando) would be less efficient to code.
  88.            
  89.